from ortools.graph import pywrapgraph
start_nodes = [0,0,0, 1,1 , 2,2,2,2 , 3,3 ,4,4 ,5]
end_nodes = [ 4,1,2 , 3,4 , 1,3,5,6 , 4,5 , 5,6 , 6 ]
capacities = [5,10,5 , 3,6 , 2,3,4,5 ,3,3 , 4,6 , 10]
max_flow = pywrapgraph.SimpleMaxFlow()
for i in range(0, len(start_nodes)):
    max_flow.AddArcWithCapacity(start_nodes[i], end_nodes[i], capacities[i])
# Find the maximum flow between node 0 and node 4.
if max_flow.Solve(0, 6) == max_flow.OPTIMAL:
    print('Max flow:', max_flow.OptimalFlow())
    print('')
    print('  Arc    Flow / Capacity')
    for i in range(max_flow.NumArcs()):
        print('%1s -> %1s   %3s  / %3s' % (
          max_flow.Tail(i),
          max_flow.Head(i),
          max_flow.Flow(i),
          max_flow.Capacity(i)))
    print('Source side min-cut:', max_flow.GetSourceSideMinCut())
    print('Sink side min-cut:', max_flow.GetSinkSideMinCut())
else:
    print('There was an issue with the max flow input.')